package com.domor.xxx.system.controller.system;

import com.domor.xxx.common.config.ServerConfig;
import com.domor.xxx.common.core.controller.BaseController;
import com.domor.xxx.framework.shiro.util.ShiroUtils;
import com.domor.xxx.system.domain.SysMenu;
import com.domor.xxx.system.domain.SysUser;
import com.domor.xxx.system.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * 首页 业务处理
 *
 * @author domor
 */
@Controller
public class SysIndexController extends BaseController {

    @Autowired
    private SysMenuService menuService;
    @Autowired
    private ServerConfig serverConfig;

    // 系统首页
    @GetMapping("/index")
    public String index(ModelMap mmap) {
        // 取身份信息
        SysUser user = ShiroUtils.getSysUser();
        // 根据用户id取出菜单
        List<SysMenu> menus = menuService.selectMenusByUser(user);
        mmap.put("menus", menus);
        mmap.put("user", user);
        mmap.put("url", serverConfig.getUrl());
        return "index";
    }

    @GetMapping("/index/console")
    public String console(){
        return "index/console";
    }

    @GetMapping("/index/home1")
    public String home1(){
        return "index/home1";
    }

    @GetMapping("/index/home2")
    public String home2(){
        return "index/home2";
    }

}
